﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master"
    CodeBehind="cakeProfile.aspx.vb" Inherits="diy_wc_prototype.cakeProfile" MaintainScrollPositionOnPostback="False"
    ValidateRequest="False" EnableEventValidation="false" %>

<%@ Import Namespace="System.Data" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">        var switchTo5x = false;</script>
    <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
    <script type="text/javascript">        stLight.options({ publisher: "148cbfe8-50b6-49fd-b788-ba5192c8c2fc" });</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ToolkitScriptManager runat="server">
    </asp:ToolkitScriptManager>
    <div class="cakeInfo">
        <div class="cakeIcons">
            <asp:ImageButton ID="goPdf2" runat="server" ImageUrl="~/img/web/font-down.png" ToolTip="PDF it!"
                CssClass="icon" />
            <div style="float: left">
                <asp:CheckBox ID="cb_fave" runat="server" CssClass="icon" AutoPostBack="True" />
                <asp:ListView ID="lv_numFaves" runat="server">
                    <ItemTemplate>
                        <%# Eval("timesFaved")%></ItemTemplate>
                    <EmptyDataTemplate>
                        0</EmptyDataTemplate>
                </asp:ListView>
            </div>
            <ajaxToolkit:ToggleButtonExtender ID="ToggleButtonExtender1" runat="server" TargetControlID="cb_fave"
                CheckedImageUrl="~/img/web/pink_heart.png" CheckedImageOverUrl="~/img/web/favorites_remove.png"
                Enabled="True" ImageHeight="24" ImageWidth="24" CheckedImageAlternateText="Faved!"
                CheckedImageOverAlternateText="Unfave" UncheckedImageAlternateText="Fave it!"
                UncheckedImageOverAlternateText="Fave it!" UncheckedImageOverUrl="~/img/web/add-fave.png"
                UncheckedImageUrl="~/img/web/heart.png">
            </ajaxToolkit:ToggleButtonExtender>
            <eo:ASPXToPDF ID="ASPXToPDF1" runat="server">
            </eo:ASPXToPDF>
        </div>
        <asp:ListView ID="lv_title" runat="server">
            <ItemTemplate>
                <div class="pageTitle">
                    <h2 class="detailsImgCaption">
                        <%# Eval("cakeTitle") %>
                    </h2>
                    by <a href='cakerProfile.aspx?userUName=<%# Eval("cakeUser")%>'>
                        <%# Eval("cakeUser")%></a>
                </div>
            </ItemTemplate>
        </asp:ListView>
    </div>
    <asp:Panel ID="panelCake" runat="server" CssClass="panelCake">
        <asp:ListView ID="lv_mainCake" runat="server">
            <ItemTemplate>
                <div id="cakeMainImg">
                    <img src='<%# Eval("cakeImg1") %>' alt='<%# Eval("cakeTitle") %>' />
                </div>
                <div class="cakeSecondaryImg">
                    <img src='<%# Eval("cakeImg2") %>' alt='' style="margin-right: 15px" />
                    <img src='<%# Eval("cakeImg3") %>' alt='' />
                </div>
                <span class='st_sharethis_large' displaytext='ShareThis'></span><span class='st_facebook_large'
                    displaytext='Facebook'></span><span class='st_twitter_large' displaytext='Tweet'>
                </span><span class='st_linkedin_large' displaytext='LinkedIn'></span><span class='st_pinterest_large'
                    displaytext='Pinterest'></span><span class='st_email_large' displaytext='Email'>
                </span>
                <h2 class="clear">
                    About my cake</h2>
                <%# Eval("cakeDesc")%>
                <br />
                <h2 class="clear">
                    How I did it</h2>
                <h3 class="clear steps">
                    Step 1</h3>
                <%# Eval("cakeStep1")%>
                <h3 class="clear steps">
                    Step 2</h3>
                <%# Eval("cakeStep2")%>
                <h3 class="clear steps">
                    Step 3</h3>
                <%# Eval("cakeStep3")%>
                <h3 class="clear steps">
                    Other stuff you need to know</h3>
                <%# Eval("cakeMisc")%>
                <br />
                </p>
            </ItemTemplate>
        </asp:ListView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:diycakeConnectionString %>"
            ProviderName="<%$ ConnectionStrings:diycakeConnectionString.ProviderName %>"
            SelectCommand="SELECT * FROM  cakeCakeUrlJunction WHERE cake_fkid = ?">
            <SelectParameters>
                <asp:QueryStringParameter Name="cake_fkid" QueryStringField="ID" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:Repeater ID="lv_cakeUrl" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
                <a href='<%# Eval("url_fkid")%>' target="_blank">
                    <%# Eval("url_fkid")%></a><br />
                <br />
            </ItemTemplate>
        </asp:Repeater>
        <h3>
            Tags</h3>
        <p>
            Help others find this cake. Add some tags (separated by commas)</p>
        <asp:TextBox ID="tb_tag" runat="server" Width="500px"></asp:TextBox>
        <asp:Button ID="btn_addTag" runat="server" Text="Add my tags" Width="120px" />
    </asp:Panel>
    <div id="consoles">
        <div class="panelUser pnlUserMargin">
            <asp:ListView ID="ParentLv" runat="server">
                <ItemTemplate>
                    <h1 class="panelTitle">
                        About this cake</h1>
                    <div class="panelLeft">
                        <b>Rated:</b>
                        <br />
                        <%# getStars(DataBinder.Eval(Container.DataItem, "cakeStar"))%>
                        <br />
                        <br />
                        <b>Difficulty:</b>
                        <br />
                        <%# getDifficulty(DataBinder.Eval(Container.DataItem, "cakeDifficulty"))%>
                        <br />
                    </div>
                    <div class="panelRight">
                        <b>Type:</b>
                        <br />
                        <%# DataBinder.Eval(Container.DataItem, "cakeType")%>
                        <br />
                        <br />
                        <b>Posted:</b>
                        <br />
                        <%# DataBinder.Eval(Container.DataItem, "cakeDateAdded", "{0:D}")%>
                        <br />
                        <br />
                    </div>
                    <h1 class="panelTitle">
                        Tags:</h1>
                    <asp:ListView ID="ChildLv" runat="server" DataSource='<%# Container.DataItem.Row.GetChildRows("cakeTagRel") %>'>
                        <ItemTemplate>
                            <div class="tagPos">
                                <br />
                                <span class="tag"><a href='cakeByTag.aspx?Tag=<%# Container.DataItem("tag")%>'>
                                    <%# Container.DataItem("tag")%>
                                </a></span>
                            </div>
                        </ItemTemplate>
                    </asp:ListView>
                </ItemTemplate>
            </asp:ListView>
        </div>
        <asp:SqlDataSource ID="ds_user" runat="server" ConnectionString="<%$ ConnectionStrings:diycakeConnectionString %>"
            ProviderName="<%$ ConnectionStrings:diycakeConnectionString.ProviderName %>"
            SelectCommand="SELECT * FROM [cakers] WHERE ([userCake] = ?)">
            <SelectParameters>
                <asp:QueryStringParameter Name="userCake" QueryStringField="ID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <div class="panelUser pnlUserMargin">
            <asp:ListView ID="userLv" runat="server" DataSourceID="ds_user">
                <ItemTemplate>
                    <img src='<%# Eval("userImg") %>' class='detailsProfilePic' alt='<%# Eval("userUName")%>' />
                    <h3 class="pnlUserName">
                        <a href='cakerProfile.aspx?userUName=<%# Eval("userUName")%>'>
                            <%# Eval("userUName")%></a></h3>
                    <div class="secLink">
                        <a href='<%# Eval("userUrl")%>'>View my website</a>
                    </div>
                    <div class="panelLeft clear">
                        <b>Rated:</b>
                        <br />
                        <%# getUserAvgRating(Eval("userAvgStar"))%>
                        <br />
                    </div>
                    <div class="panelRight">
                        <b>Age:</b>
                        <br />
                        <%# getAge(Eval("userAge"))%>
                    </div>
                    <br />
                    <br class="clear" />
                    <b>Bio:</b>
                    <br />
                    <%# Eval("userDesc") %>
                    <br />
                </ItemTemplate>
            </asp:ListView>
        </div>
        <asp:SqlDataSource ID="ds_relCakes" runat="server" ConnectionString="<%$ ConnectionStrings:diycakeConnectionString %>"
            ProviderName="<%$ ConnectionStrings:diycakeConnectionString.ProviderName %>"
            SelectCommand="SELECT TOP 3 cakeImg1, cakeType, cakeTitle, ID FROM cake WHERE cakeType IN (SELECT cakeType FROM cake WHERE ID =?) ORDER BY ID DESC">
            <SelectParameters>
                <asp:QueryStringParameter Name="?" QueryStringField="ID" />
            </SelectParameters>
        </asp:SqlDataSource>
        <div class="panelUser pnlUserMargin">
            <h1 class="panelTitle">
                Latest cakes of this type</h1>
            <asp:ListView ID="ListView1" runat="server" DataKeyNames="ID" DataSourceID="ds_relCakes"
                GroupItemCount="3">
                <GroupTemplate>
                    <tr id="itemPlaceholderContainer" runat="server">
                        <td id="itemPlaceholder" runat="server">
                        </td>
                    </tr>
                </GroupTemplate>
                <ItemTemplate>
                    <td runat="server" style="">
                        <img src='<%# Eval("cakeImg1") %>' alt='<%# Eval("cakeTitle") %>' class="commentPic relCake" />
                        <div class="relCakep">
                            <p>
                                <%# Eval("cakeTitle") %></p>
                        </div>
                        <a href='cakeProfile.aspx?ID=<%# Eval("ID") %>' class="mybtn relCakeBtn">View</a>
                    </td>
                </ItemTemplate>
                <LayoutTemplate>
                    <div style="left: 0px; width: 235px; float: left; margin: 0 auto">
                        <table runat="server">
                            <tr runat="server">
                                <td runat="server">
                                    <table id="groupPlaceholderContainer" runat="server" border="0" style="">
                                        <tr id="groupPlaceholder" runat="server">
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr runat="server">
                                <td runat="server" style="">
                                </td>
                            </tr>
                        </table>
                    </div>
                </LayoutTemplate>
            </asp:ListView>
        </div>
        <p>
            Rate this caker based on the information they have provided</p>
        <asp:Rating ID="Rating1" runat="server" StarCssClass="Star" WaitingStarCssClass="WaitingStar"
            FilledStarCssClass="FilledStar" EmptyStarCssClass="EmptyStar">
        </asp:Rating>
        <br />
        <br />
        <asp:Button ID="btn_rate" runat="server" Text="Rate" Width="120px" />
    </div>
    <asp:SqlDataSource ID="ds_noComments" runat="server" ConnectionString="<%$ ConnectionStrings:diycakeConnectionString %>"
        ProviderName="<%$ ConnectionStrings:diycakeConnectionString.ProviderName %>"
        SelectCommand="SELECT * FROM numCakeCommentsView WHERE cake_fkid = ?">
        <SelectParameters>
            <asp:QueryStringParameter Name="cake_fkid" QueryStringField="ID" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:ListView ID="commentLv" runat="server" DataSourceID="ds_noComments">
        <ItemTemplate>
            <h2 class="noComments">
                <%# Eval("numComments") %>
                Comment(s)</h2>
        </ItemTemplate>
    </asp:ListView>
    <div class="startComments clear">
        <asp:TextBox ID="tb_addComment" runat="server" Height="112px" TextMode="MultiLine"
            Width="560px" CssClass="textEntry"></asp:TextBox>
        <p>
            <b>We have a "be nice" comment policy.</b> Please be positive and constructive with
            your comments.
        </p>
        <asp:Button ID="btn_addComment" runat="server" Text="Add your comment" CssClass="mybtn loginBtn commentBtn" />
        <br />
    </div>
    <div class="commentWrapper clear">
        <asp:Repeater ID="parentRepeater" runat="server">
            <ItemTemplate>
                <div id="comment">
                    <span class="commentDate">
                        <%# DataBinder.Eval(Container.DataItem, "commentDateAdded", "{0:D}")%>
                    </span>
                    <br />
                    <a href='cakeProfile.aspx?ID=<%=Request.QueryString("ID")%>&replyTo=<%# Container.DataItem("ID")%>#reply'
                        class="right tag clear">Reply</a>
                    <img src='<%# DataBinder.Eval(Container.DataItem, "userImg") %>' class="commentPic"
                        alt="" />
                    <b><a href='cakerProfile.aspx?userUName=<%# Eval("commentAuthor")%>'>
                        <%# DataBinder.Eval(Container.DataItem, "commentAuthor")%></a> says: </b>
                    <br />
                    <span class="clear">
                        <%# DataBinder.Eval(Container.DataItem, "comment")%></span> <a href='#' class="right clear">
                            Flag</a>
                </div>
                <div class="replyWrapper">
                    <asp:Repeater ID="childRepeater" runat="server" DataSource='<%# Container.DataItem.Row.GetChildRows("myrelation") %>'>
                        <ItemTemplate>
                            <a name="<%# Container.DataItem("ID")%>"></a>
                            <div class="reply">
                                <span class="commentDate">
                                    <%# Container.DataItem("replyDateAdded")%>
                                </span>
                                <br />
                                <img src=' <%# Container.DataItem("userImg") %>' class="commentPic" alt="Profile Picture" />
                                <b><a href="<%# Container.DataItem("ID")%>"></a><a href='profile.aspx?userUName=<%# Container.DataItem("replyAuthor")%>'>
                                    <%# Container.DataItem("replyAuthor")%></a> says: </b>
                                <br />
                                <%# Container.DataItem("reply")%>
                                <a href='#' class="right clear">Flag</a>
                            </div>
                        </ItemTemplate>
                    </asp:Repeater>
                </div>
            </ItemTemplate>
        </asp:Repeater>
    </div>
    <a name="reply"></a>
    <asp:Panel ID="pnl_replyComment" runat="server" Visible="false">
        <div class="startComments clear">
            <asp:TextBox ID="tb_replyComment" runat="server" Height="112px" TextMode="MultiLine"
                Width="560px" CssClass="textEntry"></asp:TextBox>
            <p>
                <b>We have a "be nice" comment policy.</b> Please be positive and constructive with
                your comments.
            </p>
            <asp:Button ID="btn_replyComment" runat="server" Text="Reply" CssClass="mybtn loginBtn commentBtn"
                Visible="true" />
            <br />
        </div>
    </asp:Panel>
    <ajaxToolkit:HtmlEditorExtender ID="HtmlEditorExtender1" runat="server" TargetControlID="tb_addComment"
        EnableSanitization="false" ViewStateMode="Enabled">
        <Toolbar>
            <ajaxToolkit:Undo />
            <ajaxToolkit:Redo />
            <ajaxToolkit:Bold />
            <ajaxToolkit:Italic />
            <ajaxToolkit:Underline />
            <ajaxToolkit:StrikeThrough />
            <ajaxToolkit:Subscript />
            <ajaxToolkit:Superscript />
            <ajaxToolkit:JustifyLeft />
            <ajaxToolkit:JustifyCenter />
            <ajaxToolkit:JustifyRight />
            <ajaxToolkit:JustifyFull />
            <ajaxToolkit:InsertOrderedList />
            <ajaxToolkit:InsertUnorderedList />
            <ajaxToolkit:CreateLink />
            <ajaxToolkit:UnLink />
            <ajaxToolkit:RemoveFormat />
            <ajaxToolkit:SelectAll />
            <ajaxToolkit:UnSelect />
            <ajaxToolkit:Delete />
        </Toolbar>
    </ajaxToolkit:HtmlEditorExtender>
    <ajaxToolkit:HtmlEditorExtender ID="HtmlEditorExtender2" runat="server" TargetControlID="tb_replyComment"
        EnableSanitization="false" ViewStateMode="Enabled">
        <Toolbar>
            <ajaxToolkit:Undo />
            <ajaxToolkit:Redo />
            <ajaxToolkit:Bold />
            <ajaxToolkit:Italic />
            <ajaxToolkit:Underline />
            <ajaxToolkit:StrikeThrough />
            <ajaxToolkit:Subscript />
            <ajaxToolkit:Superscript />
            <ajaxToolkit:JustifyLeft />
            <ajaxToolkit:JustifyCenter />
            <ajaxToolkit:JustifyRight />
            <ajaxToolkit:JustifyFull />
            <ajaxToolkit:InsertOrderedList />
            <ajaxToolkit:InsertUnorderedList />
            <ajaxToolkit:CreateLink />
            <ajaxToolkit:UnLink />
            <ajaxToolkit:RemoveFormat />
            <ajaxToolkit:SelectAll />
            <ajaxToolkit:UnSelect />
            <ajaxToolkit:Delete />
        </Toolbar>
    </ajaxToolkit:HtmlEditorExtender>
</asp:Content>
